home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0574.ZIP / FSEEK.ASM < prev    next >
Assembly Source File  |  1986-11-20  |  791b  |  34 lines

  1. include compiler.inc
  2.     ttl    FSEEK, 1.05, 10/20/86, jwk
  3.  
  4. ;lseek for stream i/o- long lseek(handle, offsetL, base);
  5. ; returns file position, or -1L in case of error
  6. ; clears any ungetc() char, CR flag, and EOF flag
  7.  
  8.     dseg
  9.     exterr
  10.     cseg
  11.  
  12.     xtfs    <lseek,$strhand>
  13.  
  14.     procdef    fseek, <<stream, ptr>, <offlo, word>, <offhi, word>, <base, byte>>
  15.     pushreg
  16.     pushds
  17.     callit    $strhand <<stream,ptr>>
  18.     cmp    ax,-1
  19.     je    ex            ; bad stream pointer
  20.     callit    lseek,<<base,byte>,<offhi,word>,<offlo,word>,<ax,reg>>
  21.     ldptr    si,stream
  22.     mov    word ptr [si], -1    ; blank out UGC char if any
  23.     and    byte ptr 2[si], 0f7h    ; clear EOF bit
  24.     mov    byte ptr 3[si], 0    ; and CRFLG
  25.     inc    dx
  26.     jnz    ex
  27.     saverr                ; save error code
  28.     or    byte ptr 2[si],10h    ; set error flag bit
  29. ex:    dec    dx
  30.     pret
  31.     pend    fseek
  32.  
  33.     finish
  34.